package com.itheima.homework;

import java.util.ArrayList;

/**
 * @Author 王加鑫
 * @Date 2021/5/13 19:48
 * @Version 1.0
 * 5、【编号：1405】为方便管理，现需要将班级中学员的信息（学号、姓名、年龄）存储起来。请使用所学集合知识将信息遍历打印。请使用foreach语句完成集合的遍历，效果如下：
 * 姓名：吕布，学号：001，年龄：18
 * 姓名：赵云，学号：002，年龄：19
 * 姓名：典韦，学号：003，年龄：20
 * ...
 */
public class Test05 {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        Student student1 = new Student("吕布",001,18);
        Student student2 = new Student("赵云",002,19);
        Student student3 = new Student("典韦",003,20);
        list.add(student1);
        list.add(student2);
        list.add(student3);

        list.forEach(student -> System.out.println(student));

    }
}

class Student{
    private String name;
    private int sId;
    private int age;

    public Student() {
    }

    public Student(String name, int sId, int age) {
        this.name = name;
        this.sId = sId;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getsId() {
        return sId;
    }

    public void setsId(int sId) {
        this.sId = sId;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "姓名: " + name + ", 学号: " + sId + ", 年龄: " + age;

    }
}
